<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>购物订单管理</title>
<meta name="decorator" content="default" />
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnAgree").click(function() {
				var url;
				if ($("#bankId").val() == "95518") {
					
					window.location.href = "${ctxf}/refund/ali/forRefund?id=" + $("#refundId").val();
				}
				if ($("#bankId").val() == "weixin") {
					url = "${ctx}/shop/order/manage/agreeReject";
					$.ajax({
						type:"POST",
						url:url,
						data:{id:$("#refundId").val()},
						async:false,
						success:function(msg){
							
							alert(msg.message);
							window.location.href="${ctx}/shop/order/manage/";
						}
					});
				}
				
			});
			$("#btnReject").click(function() {
				window.location.href = "${ctx}/shop/order/manage/refundReject?id=" + $("#refundId").val();
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/shop/order/manage/">购物订单列表</a></li>
		<li class="active"><a
			href="${ctx}/shop/order/manage/form?id=${shopOrder.id}">购物订单<shiro:hasPermission
					name="shop:order:manage:edit">${not empty shopOrder.id?'修改':'添加'}</shiro:hasPermission>
				<shiro:lacksPermission name="shop:order:manage:edit">查看</shiro:lacksPermission></a></li>
	</ul>
	<br />
	<form:form id="inputForm" modelAttribute="shopOrder"
		action="${ctx}/shop/order/manage/save" method="post"
		class="form-horizontal">
		<form:hidden path="id" id="refundId"/>
		<form:hidden path="bankId" id="bankId"/>
		<sys:message content="${message}" />
		<div class="control-group">
			<label class="control-label">订单编号：</label>
			<div class="controls">
				<form:input path="code" htmlEscape="false" maxlength="64"
					class="input-xlarge required" disabled="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">订单总金额：</label>
			<div class="controls">
				<form:input path="totalAmount" htmlEscape="false"
					class="input-xlarge money-type" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">商品总金额：</label>
			<div class="controls">
				<form:input path="totalAmountProduct" htmlEscape="false"
					class="input-xlarge money-type" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">配送费：</label>
			<div class="controls">
				<form:input path="freight" htmlEscape="false" class="input-xlarge money-type" />
			</div>
		</div>
		<div class="control-group">
            <label class="control-label">订单支付时间：</label>
            <div class="controls">
                <input name="payTime" type="text" readonly="readonly"
                    maxlength="20" class="input-medium Wdate "
                    value="<fmt:formatDate value="${shopOrder.payTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" />
            </div>
        </div>
		<div class="control-group">
			<label class="control-label">订单创建时间：</label>
			<div class="controls">
				<input name="createTime" type="text" readonly="readonly"
					maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${shopOrder.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">下单人：</label>
			<div class="controls">
				<sys:treeselect id="account" name="account.id"
					value="${shopOrder.account.id}" labelName="account.name"
					labelValue="${shopOrder.account.username}" title="用户"
					url="/sys/office/treeData?type=3" cssClass="required"
					allowClear="true" notAllowSelectParent="true" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">订单状态：</label>
			<div class="controls">
				<form:select path="status" style="width:120px;" id="formStatus" onchange="setMoneyType()">
					<c:choose>
                  		<c:when test="${shopOrder.status == '1'}">
							<form:option value="1" disabled="disabled">待付款</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '2'}">
                  			<form:option value="2">已付款</form:option>
                  			<form:option value="3">订单确认</form:option>
                  			<form:option value="6">取消</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '3'}">
                  			<form:option value="3">订单确认</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '4'}">
                  			<form:option value="4">已发货</form:option>
							<form:option value="5">完成交易</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '5'}">
							<form:option value="5">完成交易</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '6'}">
							<form:option value="6">取消</form:option>
                  		</c:when>
                  		<c:when test="${shopOrder.status == '7'}">
							<form:option value="7">申请退款</form:option>
                  		</c:when>
                  	</c:choose>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:input path="comment" htmlEscape="false" maxlength="255"
					class="input-xlarge " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">退款理由：</label>
			<div class="controls">
				<form:input path="refundReason" htmlEscape="false" maxlength="3000"
					class="input-xlarge " />
			</div>
		</div>
		<div class="form-actions">
            <shiro:hasPermission name="shop:order:manage:edit">
                <input id="btnAgree" class="btn btn-primary" type="button"
                    value="同意退款" />&nbsp;</shiro:hasPermission>
			<shiro:hasPermission name="shop:order:manage:edit">
                <input id="btnReject" class="btn btn-primary" type="button"
                    value="驳回" />&nbsp;</shiro:hasPermission>
            <input id="btnCancel" class="btn" type="button" value="返 回"
                onclick="history.go(-1)" />
        </div>

		<!-- 商品列表 -->
		<div style="margin:20px 20px 20px 20px ;margin-b:20px; border-bottom:1px #ccc solid;"></div>
		<div style="text-align:center"><h3>商品列表</h3></div>
		<div class="control-group">
			<table class="table table-striped table-bordered table-condensed">
				<thead>
					<tr>
						<th>商品名称</th>
						<th>商品货号</th>
						<th>商品单价</th>
						<th>商品数量</th>
						<th>小计</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${shopOrder.shopOrderInfoList}"
						var="shopOrderInfo">
						<tr>
							<td>${shopOrderInfo.name }</td>
							<td>${shopOrderInfo.code }</td>
							<td>${shopOrderInfo.price }</td>
							<td>${shopOrderInfo.count }</td>
							<td>${shopOrderInfo.totalAmount }</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</form:form>
</body>
</html>